package com.samphanie.auiu.app.entity.dto;

import com.samphanie.auiu.app.entity.Permissions;
import com.samphanie.auiu.app.entity.Role;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Set;
import java.util.function.Function;

/**
 * @author ZSY
 * @email 1451691457@qq.com
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RoleDto implements Serializable {
    private static final long serialVersionUID = 3515901478224028254L;

    private Long id;

    private String roleName;

    private String displayName;

    private boolean builtIn;

    private Set<Permissions> permissions;

    public static Function<Role, RoleDto> fromRole = (role) -> RoleDto.builder()
            .id(role.getId())
            .roleName(role.getRoleName())
            .displayName(role.getDisplayName())
            .builtIn(role.isBuiltIn())
            .permissions(role.getPermissions())
            .build();

}
